package cn.edu.scau.nursingcenter.service.impl;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.scau.nursingcenter.dao.CustomerRepository;
import cn.edu.scau.nursingcenter.entiry.Customer;
import cn.edu.scau.nursingcenter.service.CustomerService;


/**
 * 业务逻辑层接口实现类CustomerServiceImpl
 * @author feng
 *
 */
@Service
public class CustomerServiceImpl implements CustomerService{
	@Autowired
	private CustomerRepository customerRepository;

	/**
	  * 查询所有客户信息
	 * @return
	 */
	@Override
	public List<Customer> selectALL() {
		return customerRepository.findAll();
	}

	/**
	 * 根据编号查询
	 * @param id
	 * @return
	 */
	@Override
	public Customer findById(Integer id) {
		Optional<Customer> optional = customerRepository.findById(id);
		return optional.isPresent()?optional.get():null;
	}

	/**
	 * 新增客户
	 * @param customer
	 * @return
	 */
	@Override
	public Customer insert(Customer customer) {
		return customerRepository.save(customer);
	}

}
